/**
 * 内容为空
*/
export function isEmpty(obj: any): boolean {
    if (Object.is(obj, null) || Object.is(obj, undefined)
        || Object.is(obj, NaN) || Object.is(obj, '')) {
        return true;
    } else if (Array.isArray(obj) && obj.length === 0) {
        return true;
    } else {
        return (typeof obj === 'object' && Object.keys(obj).length <= 0);
    }
}

/**
 * 内容非空
*/
export function notEmpty(obj: any): boolean {
    return !isEmpty(obj);
}

/**
 * 非空数组
*/
export function notEmptyArr(obj: any): boolean {
    return Array.isArray(obj) && obj.length > 0;
}

/**
 * 是否为数值
*/
export function isNumber(obj: any): obj is number {
    return Number.isFinite(obj);
}

/**
 * 是否为字符串
*/
export function isString(obj: any): obj is string {
    return typeof obj === 'string';
}

/**
 * 是否为布尔值
*/
export function isBool(obj: any): obj is boolean {
    return typeof obj === 'boolean';
}

/**
 * 是否为函数
*/
export function isFunc(obj: any): obj is Function {
    return typeof obj === 'function';
}

/**
 * 是否为颜色值
*/
export function isColor(obj: any): obj is color {
    return Number.isFinite(obj) && obj >= 0 && obj <= 0xffffff;
}

/** 
 * 是否是链接 url
 */
export function isUrl(url: string): boolean {
    return url && (url.indexOf('http://') > -1 || url.indexOf('https://') > -1);
}